package com.web.servlet;

import com.service.GoodsService;
import com.service.impl.GoodsServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/delAllGood")
public class delAllGoodServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String[] gids = request.getParameterValues("gid");
        System.out.println("gids = " + gids.length);
        //得到需要删除的所有列的id、
        GoodsService goodsService =new GoodsServiceImpl();
        if(goodsService.delAll(gids))
            request.getSession().setAttribute("operateFruit","批量删除成功");
        else
            request.getSession().setAttribute("operateFruit","批量删除成功");
        request.getRequestDispatcher("goods").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
